package com.yellowpage.bigdata.action;
  
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yellowpage.white.common.Configuration;
import com.yellowpage.white.common.Constants;
import com.yellowpage.white.struts.BaseAction;
import com.yellowpage.white.struts.Module;
import com.yellowpage.white.struts.OperationType;
import com.yellowpage.white.util.Util4Java;

import com.yellowpage.bigdata.data.TmApponoffSilentUserDay;
import com.yellowpage.bigdata.service.TmApponoffSilentUserDayService;

public class TmApponoffSilentUserDayAction extends BaseAction {

    public String RESULT_QUERY = "query";
    public String RESULT_ADD = "add";
	public String RESULT_EDIT = "edit";
	
	private Configuration configuration;
	
	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}
	
	private List<TmApponoffSilentUserDay> tmApponoffSilentUserDayList = new ArrayList<TmApponoffSilentUserDay>();
	private List<Map> resultList = new ArrayList<Map>();
	
	private TmApponoffSilentUserDay tmApponoffSilentUserDay;
	private TmApponoffSilentUserDayService tmApponoffSilentUserDayService;
	
	private String selectedId;	
	private String[] selectedIds;	
	private String message;
	
		private String query_version;
		private String query_apponoffSilentUserId;
		private String query_newUserCnts;
		private String query_silentUserCnts;
		private String query_channelNo;
		private String query_rate;
		private String query_isValide;
		private String query_dayId_start;
		private String query_dealDate;
		private String query_createUser;
		private String query_note;
		private String query_etlTime;
		private String query_dayId_end;
		
	public void prepare() {
		super.prepare();
	
		if (this.selectedId != null && !this.selectedId.equals("")) {
			this.tmApponoffSilentUserDay = tmApponoffSilentUserDayService.getTmApponoffSilentUserDay(Long.parseLong(selectedId));
		}
	}
	
	public String queryByPage() {		
		initPageRender();
		
		Map queryMap = new HashMap();	
			    queryMap.put("version", query_version);
	    	    queryMap.put("channelNo", query_channelNo);
	    	    queryMap.put("dayIdStart", query_dayId_start);
	    	    queryMap.put("dayIdEnd", query_dayId_end);
	    	    	
		resultList = tmApponoffSilentUserDayService.queryTmApponoffSilentUserDayByPage(queryMap, pageRender);
		
		setPageRenderToRequest();

		return RESULT_QUERY;
	}
	
	public String toAdd() {
		return RESULT_ADD;
	}
	
	public String save() {
	    
		tmApponoffSilentUserDayService.saveTmApponoffSilentUserDay(tmApponoffSilentUserDay);		
		
		message = "新增成功!";
		return RESULT_ADD;
	}
	
	public void validateSave() {
	    	    	    if (tmApponoffSilentUserDay.getVersion().length() == 0) {
			this.addActionError("** Version 不能为空 !");
		}
			    	    	    	    	    	    	    	    	    if (tmApponoffSilentUserDay.getChannelNo().length() == 0) {
			this.addActionError("** ChannelNo 不能为空 !");
		}
			    	    	    	    	    if (tmApponoffSilentUserDay.getIsValide().length() == 0) {
			this.addActionError("** IsValide 不能为空 !");
		}
			    	    	    if (tmApponoffSilentUserDay.getDayId().length() == 0) {
			this.addActionError("** DayId 不能为空 !");
		}
			    	    	    if (tmApponoffSilentUserDay.getDealDate().length() == 0) {
			this.addActionError("** DealDate 不能为空 !");
		}
			    	    	    	    	    if (tmApponoffSilentUserDay.getNote().length() == 0) {
			this.addActionError("** Note 不能为空 !");
		}
			    	    	    	    
		this.setValidatorResult("//TmApponoffSilentUserDayAdd.jsp");		
	}
	
	public String toEdit() {
	    Long id = new Long(selectedId);
	    
	    tmApponoffSilentUserDay = tmApponoffSilentUserDayService.getTmApponoffSilentUserDay(id);
	
		return RESULT_EDIT;
	}
	
	public String update() {
	
	    tmApponoffSilentUserDayService.updateTmApponoffSilentUserDay(tmApponoffSilentUserDay);	

		message = "修改成功!";
	    
		return RESULT_EDIT;
	}
	
	public void validateUpdate() {
					    if (tmApponoffSilentUserDay.getVersion().length() == 0) {
			this.addActionError("** Version 不能为空 !");
		}
			    			    			    			    			    if (tmApponoffSilentUserDay.getChannelNo().length() == 0) {
			this.addActionError("** ChannelNo 不能为空 !");
		}
			    			    			    if (tmApponoffSilentUserDay.getIsValide().length() == 0) {
			this.addActionError("** IsValide 不能为空 !");
		}
			    			    if (tmApponoffSilentUserDay.getDayId().length() == 0) {
			this.addActionError("** DayId 不能为空 !");
		}
			    			    if (tmApponoffSilentUserDay.getDealDate().length() == 0) {
			this.addActionError("** DealDate 不能为空 !");
		}
			    			    			    if (tmApponoffSilentUserDay.getNote().length() == 0) {
			this.addActionError("** Note 不能为空 !");
		}
			    			    		this.setValidatorResult("//TmApponoffSilentUserDayUpdate.jsp");	
	}
	
	public String delete() {	    
	    List ids = new ArrayList();
	    
		for(String id : selectedIds){
			ids.add(Long.valueOf(id));
		}
		
		try {
			this.tmApponoffSilentUserDayService.delete(ids);
		} catch (Exception e) {
			System.out.println("异常....");
			this.addActionError("** 可能含有子记录约束冲�?,删除失败 !");
		}
		
		
		return queryByPage();
	}	
	
	

	/**
	 * getters and setters
	 * 
	 * @return
	 */
	 public void setTmApponoffSilentUserDay(TmApponoffSilentUserDay tmApponoffSilentUserDay) {
		this.tmApponoffSilentUserDay = tmApponoffSilentUserDay;
	}
	
	public TmApponoffSilentUserDay getTmApponoffSilentUserDay() {
		return tmApponoffSilentUserDay;
	}
	 
	 
	 public void setTmApponoffSilentUserDayService(TmApponoffSilentUserDayService tmApponoffSilentUserDayService) {
		this.tmApponoffSilentUserDayService = tmApponoffSilentUserDayService;
	}
	
	public List<TmApponoffSilentUserDay> getTmApponoffSilentUserDayList() {
		return tmApponoffSilentUserDayList;
	}

	public void setTmApponoffSilentUserDayList(List<TmApponoffSilentUserDay> tmApponoffSilentUserDayList) {
		this.tmApponoffSilentUserDayList = tmApponoffSilentUserDayList;
	}
	
	public String getSelectedId() {
		return selectedId;
	}

	public void setSelectedId(String selectedId) {
		this.selectedId = selectedId;
	}

	public String[] getSelectedIds() {
		return selectedIds;
	}

	public void setSelectedIds(String[] selectedIds) {
		this.selectedIds = selectedIds;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public List<Map> getResultList() {
		return resultList;
	}

	public void setResultList(List<Map> resultList) {
		this.resultList = resultList;
	}
	
	    public String getQuery_version() {
        return this.query_version;
    }
    
    public void setQuery_version(String version){
        this.query_version = version;
    }    

        public String getQuery_apponoffSilentUserId() {
        return this.query_apponoffSilentUserId;
    }
    
    public void setQuery_apponoffSilentUserId(String apponoffSilentUserId){
        this.query_apponoffSilentUserId = apponoffSilentUserId;
    }    

        public String getQuery_newUserCnts() {
        return this.query_newUserCnts;
    }
    
    public void setQuery_newUserCnts(String newUserCnts){
        this.query_newUserCnts = newUserCnts;
    }    

        public String getQuery_silentUserCnts() {
        return this.query_silentUserCnts;
    }
    
    public void setQuery_silentUserCnts(String silentUserCnts){
        this.query_silentUserCnts = silentUserCnts;
    }    

        public String getQuery_channelNo() {
        return this.query_channelNo;
    }
    
    public void setQuery_channelNo(String channelNo){
        this.query_channelNo = channelNo;
    }    

        public String getQuery_rate() {
        return this.query_rate;
    }
    
    public void setQuery_rate(String rate){
        this.query_rate = rate;
    }    

        public String getQuery_isValide() {
        return this.query_isValide;
    }
    
    public void setQuery_isValide(String isValide){
        this.query_isValide = isValide;
    } 

        public String getQuery_dayId_start() {
		return query_dayId_start;
	}

	public void setQuery_dayId_start(String query_dayId_start) {
		this.query_dayId_start = query_dayId_start;
	}

	public String getQuery_dayId_end() {
		return query_dayId_end;
	}

	public void setQuery_dayId_end(String query_dayId_end) {
		this.query_dayId_end = query_dayId_end;
	}

		public String getQuery_dealDate() {
        return this.query_dealDate;
    }
    
    public void setQuery_dealDate(String dealDate){
        this.query_dealDate = dealDate;
    }    

        public String getQuery_createUser() {
        return this.query_createUser;
    }
    
    public void setQuery_createUser(String createUser){
        this.query_createUser = createUser;
    }    

        public String getQuery_note() {
        return this.query_note;
    }
    
    public void setQuery_note(String note){
        this.query_note = note;
    }    

        public String getQuery_etlTime() {
        return this.query_etlTime;
    }
    
    public void setQuery_etlTime(String etlTime){
        this.query_etlTime = etlTime;
    }    

    
	
}
